<?php
/**
 * Created by PhpStorm.
 * User: HLG
 * Date: 2019/10/14
 * Time: 16:46
 */
namespace app\api\controller;
use think\Controller;
use think\Request;

class Login extends Controller
{
    protected $user;
    public function initialize()
    {
        parent::initialize();
        header("Access-Control-Allow-Origin: *");
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
        header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, authKey, sessionId");
        header('Access-Control-Allow-Headers:x-requested-with,content-type,USER_ID,TOKEN');
        header('Content-Type:application/json; charset=utf-8');
    }
    public function __construct($app = null)
    {
        parent::__construct($app);
        $this->user = new \app\api\model\User();
    }

    /**
     * 用户注册
     */
    public function register()
    {
        $result = $this->user->register();
        AjaxReturn($result['code'],$result['msg']);
    }

    /**
     * 用户登录
     */
    public function login()
    {
        $result = $this->user->login();
        AjaxReturn($result['code'],$result['msg'],$result['data']);
    }

    /**
     * 重置密码
     */
    public function resetPassword()
    {
        $result = $this->user->resetPassword();
        AjaxReturn($result['code'],$result['msg'],$result['data']);
    }
}